package actions.main.form;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.AbstractAction;
import javax.swing.KeyStroke;

import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;
import database.DBConnection;

public class LagerListaIzvestaj extends AbstractAction {

	private static final long serialVersionUID = 1L;

	public LagerListaIzvestaj() {
		KeyStroke ctrlDKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_L,
				ActionEvent.CTRL_MASK);
		putValue(ACCELERATOR_KEY, ctrlDKeyStroke);
		putValue(SHORT_DESCRIPTION, "Izvestaj lager lista");
		putValue(NAME, "Izvestaj lager lista");
	}

	@Override
	public void actionPerformed(ActionEvent evt) {
		try {
		  JasperPrint jp = JasperFillManager.fillReport(
		  getClass().getResource("/jasper/lager.jasper").openStream(),
		  null, DBConnection.getConnection());
		  JasperViewer.viewReport(jp, false);

		} catch (Exception ex) {
		  ex.printStackTrace();
		}
	}

}
